function RouteType(select, def) {
  var rtlist = [
  [0, "Tram, Streetcar, Light rail"],
  [1, "Subway, Metro"],
  [2, "Rail"],
  [3, "Bus"],
  [4, "Ferry"],
  [5, "Cable car"],
  [6, "Gondola, Suspended cable car"],
  [7, "Funicular"]
  ];
  for (var i = 0; i < rtlist.length; i++) {
    var v = rtlist[i];
    select.options[select.options.length] = new Option(v[1], v[0], def == v[0], def == v[0]);
  }
}

(function(jQuery) {
  window.onload = function() {
    var dom = function(id) {
      return document.getElementById(id);
    }
    var routetype = dom('route_type');
    RouteType(routetype, route_type);
    function checkUrl() {
      var check = (!dom("route_url").value || validator.isUrl(dom("route_url").value));
      if (!check) {
        alert("URL NOT VALIDATE");
      }
      return check;
    }

    function checkColor() {
      var check = (!dom("route_color").value || validator.isHex(dom("route_color").value));
      if (!check) {
        alert("Color NOT VALIDATE");
      }
      return check;
    }
    
    function checkTextColor() {
      var check = (!dom("route_text_color").value || validator.isHex(dom("route_text_color").value));
      if (!check) {
        alert("Text Color NOT VALIDATE");
      }
      return check;
    }


    function formcheck() {
      return  checkUrl() &&
      validator.isName(dom("route_id").value) &&
      validator.Ascii(dom("route_short_name").value) &&
      validator.isName(dom("route_long_name").value) &&
      checkColor() && checkTextColor();
    }
     
    $('#editorform').submit(function (){
      var check = formcheck();
      alert(check);
      return check;
    })
     
  }
})();
